/**
 * Advanced Software Engineering (Monica Farrow)
 * UncollectedParcelDaysComparator class
 * 
 * The structure of this class has been based on lecture notes provided by
 * Monica Farrow as a part of Software Engineering courses at Heriot-Watt University.
 */

package depotAdmin;

import java.util.Comparator;

import depot.Parcel;

/**
 * UncollectedParcelDaysComparator class allowing 2 parcels to be ordered
 * by number of days in depot
 * @author Ionut Iordache, Nikky Afunugo, Dave Bond
 */
public class UncollectedParcelDaysComparator implements Comparator<Parcel> {

	/** 
	 * returns an int - 1, 0, or -1
	 * resulting from the comparison of the two Parcel objects
	 * allowing them to be places in days in depot order
	 * @param p1  the 1st Parcel to be compared
	 * @param p2  the 2nd Parcel to be compared
	 * @return the comparison int
	 */	
	public int compare(Parcel p1, Parcel p2) {
		//encapsulate p1 object into an instance of Integer
		Integer p = new Integer(p2.getDays());
		// compare p with p2 and return the ID
		return p.compareTo(p1.getDays());
	}
}